package main

import "fmt"

type People interface {
	Speak(string) string
}
type Student struct {
}

// way 2
//func (stu *Student)Speak(think string) (talk string) {
// 或者
func (stu Student) Speak(think string) (talk string) {
	if think == "bitch" {
		talk = "You are a good boy"
	} else {
		talk = "hi"
	}
	return
}

//结论：编译失败，值类型 Student{} 未实现接口People的方法，不能定义为 People 类型。
//总结：指针类型的结构体对象可以同时调用结构体值类型和指针类型对应的方法。而值类型的结构体对象只能调用值类型对应的接口方法。
func main() {
	//error
	//var peo People = Student{}
	//think := "bitch"
	//fmt.Println(peo.Speak(think))
	// way 1
	// 指针类型结构体,可以调用 -- 结构体值类型和指针类型对应的方法
	var peo People = &Student{}
	think := "bitch"
	fmt.Println(peo.Speak(think))

}
